home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2000 #5
/
Amiga Plus CD - 2000 - No. 5.iso
/
Tools
/
Dev
/
Real
/
realprefs_old.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-02
|
8KB
|
323 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Miîosîaw Smyk
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include <clib/diskfont_protos.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/gadtools_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/utility_pragmas.h>
#include <proto/diskfont.h>
#include "wfmhcybergfx_key.h"
#include "realprefs.h"
extern struct KeyBase *KeyBase;
struct Screen *Scr = NULL;
UBYTE *PubScreenName = NULL;
APTR VisualInfo = NULL;
struct Window *RealPrefsWnd = NULL;
struct Gadget *RealPrefsGList = NULL;
struct IntuiMessage RealPrefsMsg;
struct Gadget *RealPrefsGadgets[4];
UWORD RealPrefsLeft = 50;
UWORD RealPrefsTop = 150;
UWORD RealPrefsWidth = 263;
UWORD RealPrefsHeight = 49;
UBYTE *RealPrefsWdt = (UBYTE *)"wfmhcybergfx_r3d.library";
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
struct TextFont *RealPrefsFont = NULL;
int public;
UBYTE *Gadget000Labels[] = {
(UBYTE *)"Floyd-Steinberg",
(UBYTE *)"Ordered 4x4",
(UBYTE *)"None",
NULL };
UWORD RealPrefsGTypes[] = {
CYCLE_KIND,
BUTTON_KIND,
BUTTON_KIND,
BUTTON_KIND
};
struct NewGadget RealPrefsNGad[] = {
92, 6, 160, 14, (UBYTE *)"_Dithering", NULL, GD_Gadget00, PLACETEXT_LEFT, NULL, (APTR)Gadget00Clicked,
10, 30, 76, 14, (UBYTE *)"_Save", NULL, GD_Gadget10, PLACETEXT_IN, NULL, (APTR)Gadget10Clicked,
176, 30, 76, 14, (UBYTE *)"_Cancel", NULL, GD_Gadget20, PLACETEXT_IN, NULL, (APTR)Gadget20Clicked,
94, 30, 76, 14, (UBYTE *)"_Use", NULL, GD_Gadget30, PLACETEXT_IN, NULL, (APTR)Gadget30Clicked
};
ULONG RealPrefsGTags[] = {
(GTCY_Labels), (ULONG)&Gadget000Labels[ 0 ], (GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE),
(GT_Underscore), '_', (TAG_DONE)
};
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Forbid();
Font = &Attr;
Font->ta_Name = (STRPTR)GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
FontX = GfxBase->DefaultFont->tf_XSize;
Permit();
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen(struct Screen *scr)
{
if(scr)
{
Scr = scr;
public = FALSE;
}
else
{
public = TRUE;
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
}
ComputeFont( 0, 0 );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if(Scr && public)
UnlockPubScreen(NULL, Scr);
Scr = NULL;
}
void RealPrefsRender( void )
{
ComputeFont( RealPrefsWidth, RealPrefsHeight );
DrawBevelBox( RealPrefsWnd->RPort, OffX + ComputeX( 0 ),
OffY + ComputeY( 0 ),
ComputeX( 263 ),
ComputeY( 49 ),
GT_VisualInfo, VisualInfo, TAG_DONE );
}
int HandleRealPrefsIDCMP( void )
{
struct IntuiMessage *m;
int (*func)();
BOOL running = TRUE;
ULONG cycle;
WaitPort(RealPrefsWnd->UserPort);
while( m = GT_GetIMsg( RealPrefsWnd->UserPort )) {
CopyMem(( char * )m, ( char * )&RealPrefsMsg, (long)sizeof( struct IntuiMessage ));
GT_ReplyIMsg( m );
switch ( RealPrefsMsg.Class ) {
case IDCMP_CHANGEWINDOW:
RealPrefsLeft = RealPrefsWnd->LeftEdge;
RealPrefsTop = RealPrefsWnd->TopEdge;
break;
case IDCMP_REFRESHWINDOW:
GT_BeginRefresh( RealPrefsWnd );
RealPrefsRender();
GT_EndRefresh( RealPrefsWnd, TRUE );
break;
case IDCMP_CLOSEWINDOW:
running = RealPrefsCloseWindow();
break;
case IDCMP_GADGETUP:
func = ( void * )(( struct Gadget * )RealPrefsMsg.IAddress )->UserData;
running = func();
break;
case IDCMP_VANILLAKEY:
switch(RealPrefsMsg.Code)
{
case 's':
case 'S':
running = Gadget10Clicked();
break;
case 'u':
case 'U':
running = Gadget30Clicked();
break;
case '\x1b':
case 'c':
case 'C':
running = Gadget20Clicked();
break;
case 'd':
case 'D':
GT_GetGadgetAttrs(RealPrefsGadgets[0], RealPrefsWnd, NULL, GTCY_Active, &cycle);
if(RealPrefsMsg.Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
cycle = cycle == 0 ? 2 : cycle - 1;
else
cycle = cycle == 2 ? 0 : cycle + 1;
GT_SetGadgetAttrs(RealPrefsGadgets[0], RealPrefsWnd, NULL, GTCY_Active, cycle);
running = Gadget00Clicked();
break;
}
break;
}
}
return( running );
}
int OpenRealPrefsWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = RealPrefsLeft, wtop = RealPrefsTop, ww, wh;
ComputeFont( RealPrefsWidth, RealPrefsHeight );
ww = ComputeX( RealPrefsWidth );
wh = ComputeY( RealPrefsHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( RealPrefsFont = OpenDiskFont( Font )))
return( 5L );
if ( ! ( g = CreateContext( &RealPrefsGList )))
return( 1L );
for( lc = 0, tc = 0; lc < RealPrefs_CNT; lc++ ) {
CopyMem((char * )&RealPrefsNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
RealPrefsGadgets[ lc ] = g = CreateGadgetA((ULONG)RealPrefsGTypes[ lc ], g, &ng, ( struct TagItem * )&RealPrefsGTags[ tc ] );
while( RealPrefsGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
GT_SetGadgetAttrs(RealPrefsGadgets[0], RealPrefsWnd, NULL, GTCY_Active, KeyBase->dither_type);
if ( ! ( RealPrefsWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, CYCLEIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_CHANGEWINDOW|IDCMP_VANILLAKEY,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP,
WA_Gadgets, RealPrefsGList,
WA_Title, RealPrefsWdt,
WA_ScreenTitle, "wfmhcybergfx_r3d.library ©1995-97 Miloslaw Smyk (thorgal@dedal.man.szczecin.pl)",
WA_PubScreen, Scr,
TAG_DONE )))
return( 4L );
GT_RefreshWindow( RealPrefsWnd, NULL );
RealPrefsRender();
return( 0L );
}
void CloseRealPrefsWindow( void )
{
if ( RealPrefsWnd ) {
CloseWindow( RealPrefsWnd );
RealPrefsWnd = NULL;
}
if ( RealPrefsGList ) {
FreeGadgets( RealPrefsGList );
RealPrefsGList = NULL;
}
if ( RealPrefsFont ) {
CloseFont( RealPrefsFont );
RealPrefsFont = NULL;
}
}